﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using vnCommonGUI;
using vnBiometricsSDK.FingerPrint;
using System.Diagnostics;

namespace vnFingerPrint.GUI
{
    public partial class Frm1vs1Compare : Form
    {
        Stopwatch stop = new Stopwatch();
        private double[] dactrung1;
        private double[] dactrung2;
        Bitmap bmp1 = new Bitmap(512, 512);
        Bitmap bmp2 = new Bitmap(512, 512);
        public Frm1vs1Compare()
        {
            InitializeComponent();
            btnCompare.Enabled = canRun();
        }
        bool canRun()
        {
            if (pictureBox1.Image != null && pictureBox2.Image != null) return true;
            return false;
        }
        private void btnOpenImage1_Click(object sender, EventArgs e)
        {
            pictureBox1.Image = CommonFunction.OpenDialogImageFile();
            if (pictureBox1.Image != null)
            {
                bmp1 = vnSumarySDK.CaiThienAnh((Bitmap)pictureBox1.Image);
                dactrung1 = vnSumarySDK.LayDacTrung(bmp1);
            }
            btnCompare.Enabled = canRun();
        }

        private void btnOpenImage2_Click(object sender, EventArgs e)
        {
            pictureBox2.Image = CommonFunction.OpenDialogImageFile();

            if (pictureBox2.Image != null)
            {
                bmp2 = vnSumarySDK.CaiThienAnh((Bitmap)pictureBox2.Image);
                dactrung2 = vnSumarySDK.LayDacTrung(bmp2);
            }
            btnCompare.Enabled = canRun();
        }

        private void btnCompare_Click(object sender, EventArgs e)
        {
            //pictureBox1.Image = vnSumarySDK.LayAnhDacTrung(bmp1);
            //pictureBox2.Image = bmp2;
            int i = vnSumarySDK.PhanTramPhuHop(dactrung1, dactrung2);
            lblResult.Text = i.ToString() + " % phù hợp";
        }
    }
}
